import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'



import App from './App.vue'
import router from './router'
import store from './store'

// axios.defaults.baseURL = '/api';
// axios.defaults.timeout = 8000; 
// 根据环境变量获取不同的请求地址
// axios.defaults.baseURL = env.baseURL;
// 接口错误拦截
axios.interceptors.response.use(function(response){
  let res = response.data;
  let path = location.hash;
  if(res.status == 200){
    return res.data;
  }else if(res.status == 10){
    if (path != '#/index'){
      window.location.href = '/#/login';
    }
    return Promise.reject(res);
  }else{
    
    return Promise.reject(res);
  }
},(error)=>{
  //let res = error.response;

  
  return Promise.reject(error);
});


Vue.config.productionTip = false;

Vue.use(VueAxios,axios);
Vue.use(ElementUI);

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
